package cn.walls1717.wallsmall.product.web;

import cn.walls1717.wallsmall.product.service.SkuInfoService;
import cn.walls1717.wallsmall.product.vo.SkuItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

/**
 * 商品详情
 *
 * @author walls1717
 * @since 2022/11/09 19:51
 **/
@Slf4j
@Controller
public class ItemController {
    @Resource
    private SkuInfoService skuInfoService;

    /** 展示sku详情 */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable Long skuId, Model model) {
        log.info("查询 -> {}的详情", skuId);
        SkuItemVO skuItemVO = skuInfoService.getItemBySkuId(skuId);
        model.addAttribute("item", skuItemVO);
        return "item";
    }
}
